import { axiosMock, delayFn, randArrItem } from '@/services/axiosMock'
import { IWaybillInfo } from '../interface'

axiosMock('default', mock => {
  // 获取运单基础信息
  mock.onPost(`/tmsapi/waybill_record/waybillInfo`).reply(
    delayFn<IWaybillInfo>(600, () => {
      const currentLogisticsNode = randArrItem([0, 1, 2, 3, 4, 5, 6])
      return {
        success: true,
        data: {
          abnormalStatus: randArrItem([-1, -1, 0, 0, 1], 0.1),
          deliverDate: randArrItem([`2023-12-11`, `2024-12-11`], 0.1),
          age: randArrItem(['12', '13'], 0.1),
          currentLogisticsNode,
          logisticsNodeList: [0, 1, 2, 3, 4, 5, 6],
          archiveFlag: currentLogisticsNode === 6 ? randArrItem([0, 1]) : 0,
        },
      }
    }),
  )

  // 处理异常
  mock.onPost(`/tmsapi/waybill_record/handleAbnormal`).reply(
    delayFn<IWaybillInfo>(600, () => {
      return {
        success: true,
      }
    }),
  )

  // 处理归档
  mock.onPost(`/tmsapi/waybill_record/archive`).reply(
    delayFn<IWaybillInfo>(600, () => {
      return {
        success: true,
      }
    }),
  )
})
